#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=100000, maxm=100000;

class Graph {
public:
  int n, m, ind[maxn+1], to[2*maxn+1], link[2*maxn+1];

  void addSide(int u, int v) {
    m++;
    to[m] = v;
    link[m] = ind[u];
    ind[u] = m;
  }

  int solve(int o, int fa, int m, int *x, int *y) {
    static bool book[maxn+1];
    book[o] = true;
    for (int i=1; i<=m; i++) {
      if (book[x[i]] && book[y[i]]) {
	book[o] = false;
	return 0;
      }
    }
    int ret=1;
    for (int i=ind[o]; i; i=link[i]) {
      if (to[i]!=fa) {
	ret += solve(to[i], o, m, x, y);
      }
    }
    book[o] = false;
    return ret;
  }
};

int main() {
  freopen("tree.in", "r", stdin);
  freopen("tree.out", "w", stdout);

  static Graph g;
  bool flag=true;
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i=1; i<n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    g.addSide(u, v);
    g.addSide(v, u);
    flag = flag && (u==1 || v==1);
  }
  if (flag) {
    static int x[maxm+1], y[maxm+1];
    static bool book[maxn+1];
    int ans=0, t=n;
    for (int i=1; i<=m; i++) {
      scanf("%d %d", x+i, y+i);
      if (x[i]==1) {
	book[y[i]] = true;
	t--;
      } else if (y[i]==1) {
	book[x[i]] = true;
	t--;
      }
    }
    ans = t*(t-1)/2;
    for (int i=1; i<=m; i++) {
      if (x[i]!=1 && y[i]!=1 && !book[x[i]] && !book[y[i]]) {
	ans-=1;
      }
    }
    printf("%d", ans);
  } else {
    static int x[maxm+1], y[maxm+1];
    for (int i=1; i<=m; i++) {
      scanf("%d %d", x+i, y+i);
    }
    int ans=0;
    for (int i=1; i<=n; i++) {
      ans += g.solve(i, 0, m, x, y)-1;
    }
    printf("%d", ans/2);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
